#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<errno.h>
#include<fcntl.h>
#include<unistd.h> 
#include<pthread.h>

int
main(int argc, char* args[])
{
	int f[2];
	printf("\n%d %d\n",f[0],f[1]);
	pipe(f);
	
	char* str = "hellow world\n";
	char buf[1024] = "hellow world";
	int pid;
	pid = fork();
	if(pid < 0){
		perror("fork error");
		exit(1);
	}
	else if(pid){
		close(f[0]);
		if(write(f[1], str,  strlen(str)) < 0){
			perror("write error");
			exit(1);
		}
		close(f[1]);
	}
	else if(!pid){
		close(f[1]);
		if(read(f[0], buf, strlen(str)) < 0){
			perror("read error");
			exit(1);
		}
		if(write(STDOUT_FILENO, buf, strlen(buf)) < 0){
			perror("write error");
			exit(1);
		}

	}
	
	exit(0);
}
